﻿using System.Data.OracleClient;
using System.Xml.Linq;
using Microsoft.VisualStudio.DebuggerVisualizers;
using OracleCommandVisualizer;

[assembly:System.Diagnostics.DebuggerVisualizer(
    typeof(DebuggerVisualizer), 
    typeof(OracleCommandVisualizerObjectSource), 
    Target = typeof(OracleCommand), 
    Description = "Afa OracleCommand Viewer")]
namespace OracleCommandVisualizer
{
    //REF: http://msdn.microsoft.com/en-us/library/ms164759.aspx
    public class DebuggerVisualizer : DialogDebuggerVisualizer
    {
        protected override void Show(
            IDialogVisualizerService windowService, 
            IVisualizerObjectProvider objectProvider)
        {
            VisualizerForm vf = new VisualizerForm(
                XDocument.Parse(objectProvider.GetObject().ToString()));
            vf.ShowDialog();
        }

        public static void TestShowVisualizer(object objectToVisualize)
        {
            VisualizerDevelopmentHost host = 
                new VisualizerDevelopmentHost(
                    objectToVisualize, typeof(DebuggerVisualizer),
                    typeof(OracleCommandVisualizerObjectSource));
            host.ShowVisualizer();
        }
    }
}
